<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="box">这是一个div</div>
    <script>
        /* 在div身上绑定一个点击事件,然后触发function这个匿名函数 */
        box.onclick = function(){
            console.log("执行这段代码");
        }
    </script>
</body>
</html>